/*
 * @lc app=leetcode.cn id=141 lang=javascript
 *
 * [141] 环形链表
 */

// @lc code=start
/**
 * Definition for singly-linked list.
 * function ListNode(val) {
 *     this.val = val;
 *     this.next = null;
 * }
 */

/**
 * @param {ListNode} head
 * @return {boolean}
 */
 var hasCycle = function(head) {
     // 快慢指针 判环
    if (!head || !head.next) return false
    let s = head;
    let f = head.next;
    while(s!==f && f?.next ) {
          f = f.next.next;
          s = s.next;
    }
    return f === s;
};
// @lc code=end

